// index.js
const api = require('../../api/api')
const util = require('../../utils/js/util')
Page({
  data: {
    safeToBottom: util.getSafeToBottom(),
    list: [],
    page: 1,
    list_status_text: '加载中'
  },
  onLoad(options) {
    this.getlist()
  },
  async getlist() {
    const { list, page } = this.data
    const res = await api.getInviteList({ page })
    this.setData({ 
      list: list.concat(res.data.map(v=>({...v, jointime: util.getDateTime(v.jointime * 1000).format('Y-M-D h:m:s')}))), 
      list_status_text: res.data.length == 0 && page == 1 ? '暂无数据' : res.current_page == res.last_page ? '没有更多数据了' : '加载中' 
    })
  },
  onReachBottom() {
    this.setData({ page: this.data.page + 1 });
    this.getlist();
  }
});